package com.wzh.mall.product.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.io.IOException;

/**
 * @program: mall
 * @description: Redisson的配置类
 * @author: Mr.Wang
 * @create: 2021-09-10 10:44
 **/
@Configuration
public class MyRedissonConfig {



    /**
      * @Description: 所有对redisson的使用都是通过RedissonClient对象
      * @Param: []
      * @return: org.redisson.api.RedissonClient
      * @Author: Mr.Wang
      * @Date: 2021/9/10
      * @Time: 11:05
      */      
      
    @Bean(destroyMethod="shutdown")
    public RedissonClient redisson() throws IOException {
        // 创建配置
        Config config = new Config();
        config.useSingleServer().setAddress("redis://192.168.44.129:6379");
        // 根据config创建出实例
        RedissonClient redissonClient = Redisson.create(config);
        return redissonClient;
    }


}
